var userinfo = {name: 'myfuder'};

var present = {
    init: function () {
        this.getData();
    },
    eventLisenter: function () {
        $(".all").click(function () {
            var count = $(".allCount").text();
            if (count > 0) {
                $(".sendCount").val(count);
                $(".submit button").css("background", "#cba86a");
                console.log(count);
            }
        });
        $(".sendCount").on('input', function (e) {
            var count = $(".allCount").text();
            if ($(".sendCount").val() > 0&&$(".sendCount").val()<count||$(".sendCount").val()==count) {
                $(".submit button").css("background", "#cba86a");
            } else {
                $(".submit button").css("background", "#d3d3d3");
            }
        });
        $(".sendbtn").click(function(){
            present.sendG();
        });
    },
    getData: function () {
        new AjaxRequest({
            type: "get",
            url: apiService.getMyGuobiCount,
            param: "",
            callBack: function (res) {
                $(".allCount").text(res.payload);
            },
            failBack: function () {
            }
        });
    },
    sendG:function(){
        new AjaxRequest({
            type: "get",
            // url: "https://5ae979d7531a580014142797.mockapi.io/api/v1/records",
            url:apiService.sendGuobi,
            param: JSON.stringify({data:$('input').val()}),
            callBack:function(res){
                if(res.success){
                    $("body").append(popdom);
                }else{
                    alert(res.message);
                }
            },
            failBack: function(){
            }
        });
    }
}
function removes(dom){
    $(dom).remove();
}
var popdom = `<div class="popwindow" onclick="removes(this)">
        <div class="pop-ur">
            <img src="../../img/popullarize/p2.png"/>
        </div>
        <div class="popbot flexs-center">
            <div class="pop-l">
                <img src="../../img/popullarize/s.png"/>
                <p>发送好友</p>
            </div>
        </div>
        <div class="toasttext">
            戳这里，分享给好友！
        </div>
    </div>`;